<template>
	<view>
		新闻页面
		<!-- 使用组件 -->
		<test :msg="msg" @testShowName="testEvent"></test>
		<text>{{msg}}</text>
		<text>{{"msg".indexOf('s')==1 ? '赚钱了':'no'}}</text>
		<image :src="url" mode=""></image>
		<view :class="{demo:true}" :style="{width:'100px;color:red'}">你好</view>
		<view :class="['demo','demo1']" :style="[{width:'100px;color:red'}]">你好1</view>
		<view :class="{demo1:index==currentIndex}" 
		v-for="(item,index) in favors" :key="index"
		@click="setIndexNum(index)"
		>
			<view class="">爱好:{{item}}</view>
		</view>
	</view>
</template>

<script>
	//引入组件文件
	import test from '../../components/test.vue';
	export default {
		data() {
			return {
				msg: 'admin',
				url: "https://dss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo_top-e3b63a0b1b.png",
				favors: ['football', 'swiming', 'jump'],
				currentIndex:0
			}
		},
		//加入组件
		components: {
			test
		},
		methods: {
			testEvent(rel) {
				console.log(rel);
			},
			setIndexNum(index){
				this.currentIndex=index;
			}
			
		},
		onLoad() {
			// 全局定义事件
			// uni.$on("testEmit",(rel)=>{
			// 	console.log(rel);
			// })
			uni.$once("testEmit", (rel) => {
				console.log(rel);
			})
		}
	}
</script>

<style>
	.demo {
		border: 1px solid #007AFF;

	}

	.demo1 {
		background-color: #C0C0C0;
	}
</style>
